package org.demo.service.springboot;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@EnableDiscoveryClient
//@EnableAutoConfiguration
@RestController
public class HelloApplication {
	
	private Logger logger = Logger.getLogger(HelloApplication.class);
	
	@Autowired
	private DiscoveryClient client;

	@RequestMapping("/hello")
	public String index(String username, String password){
		ServiceInstance instance = client.getLocalServiceInstance();
		logger.info(instance.getHost()+" "+instance.getServiceId());
		return "Hello Spring Boot!" + username +" : "+ password;
	}
	
	public static void main(String[] args) {
        SpringApplication.run(HelloApplication.class, args);
    }
}
